<?php
	require_once("../../library/function/connect.php");
	require_once("../../library/function/MasterTool.php");
	$obj = new MasterTool();
	
	$name = $_POST("#name");
	$phone = $_POST("#phone");
	$address = $_POST("#address");
	$email = $_POST("#email");
	$website = $_POST("#website");
	$des = $_POST("#des");
	$create_date = $obj->CurrentDate() . " " . $obj->CurrentTime();
	
	$category = $_POST("#category");
	$title = $_POST("#title");
	$alias = $obj->str_alias($obj->vn_str_filter($title));
	$date_begin = $_POST("#date_begin");
	$date_end = $_POST("#date_end");
	$content = $_POST("#content");
	
	$query = mysql_query(" INSERT INTO congty(name,`address`,phone,email,website,description,create_date)
				VALUES(N'$name', N'$address', '$phone', '$email', '$website', N'$des', '$create_date') ");
	if($query)
	{
		$row = mysql_fetch_array(mysql_query(" SELECT max(id) mx FROM congty WHERE name != '' "));
		$company = $row['mx'];
		$query_congviec = mysql_query(" INSERT INTO congviec(company, category, name, alias, content, date_begin, date_end, create_date)
		VALUES('$company', '$category', N'$title', '$alias', N'$content', '$date_begin', '$date_end', '$create_date') ");
		
		if($query_congviec)
			echo "0";
		else
			echo "1";
	}
	else
		echo "1";
?>